#ifndef __PATHTRACER_H__
#define __PATHTRACER_H__

#include "common/color.h"
#include "common/camera.h"
#include "common/scene.h"
#include "common/image.h"
#include "math/ray.h"
#include "math/vector.h"
#include "object/object.h"

namespace Sirat {

namespace Path_Tracing {
typedef std::vector<tuple<Object::Object*, Math::Vector, Common::Color, double> > Path;

class Path_Tracer {
public:
	Path_Tracer(Common::Scene* _scene, Common::Camera* _camera, const unsigned int _path_number, const unsigned int _path_depth);
	Path_Tracer(const Path_Tracer& _other);

	void render();
	void set_output(Common::Image* _image);
	
	#ifdef _OPENMP
	void set_parallel(const bool _parallel);
	void set_threads(const unsigned int _threads);
	#endif
private:
	Common::Color calculate_color(Object::Object* _object, Math::Ray _ray, Math::Vector _point);
	Math::Ray get_random_ray(Math::Vector _point, Math::Vector normal);
	Path construct_path(Object::Object* _object, Math::Vector _point, unsigned int _depth);
	Common::Color path_illumination(Object::Object* _object, Math::Vector _point, Path path);
	Common::Scene* scene;
	Common::Camera* camera;
	Common::Image* image;

	unsigned int path_number;
	unsigned int path_depth;
	#ifdef _OPENMP
	bool parallel;
	unsigned int threads_number;
	#endif
};

}

}

#endif
